//author:jxx
//此处是对表单的方法，组件，权限操作按钮等进行任意扩展(方法扩展可参照SellOrder.js)
let extension = {
  components: {
    //动态扩充组件或组件路径
    //表单header、content、footer对应位置扩充的组件
    gridHeader: "", //{ template: "<div>扩展组xx件</div>" },
    gridBody: "",
    gridFooter: "",
    //弹出框(修改、编辑、查看)header、content、footer对应位置扩充的组件
    modelHeader: "",
    modelBody: "",
    modelFooter: () =>
      import("../../views/mall/mebcardChild/conditionManagement.vue")
  },
  buttons: { view: [], box: [], detail: [] }, //扩展的按钮
  data() {
    return {
      rowId: {} //id
    };
  },
  methods: {
    //事件扩展
    onInit() {
      // 弹框宽度
      this.boxOptions.width = 800;
      this.boxOptions.height = 600;
      this.$store.getters.data().reportPrice = this;
    },
    rowClick({ row, column, event }) {
      //查询界面table点击行选中当前行
      this.$refs.table.$refs.table.toggleRowSelection(row);
      return true;
    },
    modelOpenAfter(row) {
      if (this.currentAction != "Add") {
        console.log("编辑", row);
        this.rowId = row.id;
        let params = {
          order: "desc",
          page: 1,
          rows: 100,
          sort: "id",
          wheres: `[{\"name\":\"id\",\"value\":\"${this.rowId
          }\",\"displayType\":\"text\"}]`
        };
        this.http
          .post("/api/Mall_preferential_scheme/getPageData", params)
          .then(res => {
            if (res.rows[0].json!=null) {
              this.$refs.modelFooter.tableData = JSON.parse(res.rows[0].json)
         
        
            }
          });
      
      } else {
        this.$refs.modelFooter.tableData = [];
      }
    },
    addBefore(formData) {
   
      // formData.spare4 = this.$refs.modelFooter.radio
      // formData.spare5 = this.$refs.modelFooter.hotelData
      //新建保存前formData为对象，包括明细表
      // if (formData.detailData.length != 0) {
      //   formData.detailData.forEach(i => {
      //     i.isDelete = 0
      //   })
      // }
      return this.veriFromTable(formData);
    },
    updateBefore(formData) {
      // formData.spare4 = this.$refs.modelFooter.radio
      // formData.spare5 = this.$refs.modelFooter.hotelData
      return this.veriFromTable(formData);
    },
    veriFromTable(formData) {
      console.log(this.$refs.modelFooter.tableData, "----");
      formData.mainData.json = this.$refs.modelFooter.tableData;
      console.log(formData, "formData");
      return true;
    }
  }
};
export default extension;
